package com.orange.base.component.biztool.simulateddata.service.impl;

import com.orange.base.component.biztool.simulateddata.service.SimulatedDataEnum;
import com.orange.base.component.biztool.simulateddata.service.SimulatedDataParam;

/**
 * 生成随机编号
 *
 * @author biankudingcha
 * @date: 2022-08-24
 * @since 0.5.0
 */
public class SerialNumberStrategy extends AbstractSimulatedData {

    public String getType() {
        return SimulatedDataEnum.SERIAL_NUMBER.getName();
    }

    public String getCaption() {
        return SimulatedDataEnum.SERIAL_NUMBER.getCaption();
    }

    @Override
    public Object getValue(SimulatedDataParam param) {
        return generate(param);
    }

    private static String generate(SimulatedDataParam param) {
        int length = 10;
        if (!isEmpty(param.getMax())) {
            length = toInt(param.getMax());
        }
        return randomNumbers(length);
    }

    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 10; i++) {
            System.out.print(generate(null));
            System.out.print("\t");
            System.out.print(generate(null));
            System.out.print("\t");
            System.out.print(generate(null));
            System.out.print("\t");
            System.out.println(generate(null));
        }
    }

}
